﻿using System;
using fastCSharp.code.cSharp;
using fastCSharp;

namespace diantou.web.ajax.api
{
    /// <summary>
    /// 问题操作
    /// </summary>
    [fastCSharp.code.cSharp.ajax(IsPool = true)]
    class problem : jsonHandle<problem>
    {
        /// <summary>
        /// 添加问题
        /// </summary>
        /// <param name="token"></param>
        /// <param name="problem"></param>
        /// <param name="onReturn"></param>
        [fastCSharp.code.cSharp.ajax(IsReferer = false)]
        public void Append(string token, diantou.dataAccess.problem problem, Action<fastCSharp.net.returnValue<fastCSharp.openApi._51nod.returnValue<int>.value>> onReturn)
        {
            if (token == null || problem == null || !fastCSharp.stringExpand.Trim(ref problem.Title)) onReturn(default(fastCSharp.openApi._51nod.returnValue<int>.value));
            else diantou.dataAccess.tcpCall.openJudge.appendProblem(token, problem, onReturn);
        }
        /// <summary>
        /// 修改问题
        /// </summary>
        /// <param name="token"></param>
        /// <param name="problem"></param>
        /// <param name="onReturn"></param>
        [fastCSharp.code.cSharp.ajax(IsReferer = false)]
        public void Rework(string token, diantou.dataAccess.problem problem, Action<fastCSharp.net.returnValue<fastCSharp.openApi._51nod.returnValue.value>> onReturn)
        {
            if (token == null || problem == null || !fastCSharp.stringExpand.Trim(ref problem.Title)) onReturn(default(fastCSharp.openApi._51nod.returnValue.value));
            else diantou.dataAccess.tcpCall.openJudge.reworkProblem(token, problem, onReturn);
        }
        ///// <summary>
        ///// 修改测试数据
        ///// </summary>
        ///// <param name="token"></param>
        ///// <param name="problemId"></param>
        ///// <param name="datas"></param>
        ///// <param name="onReturn"></param>
        //[fastCSharp.code.cSharp.ajax(MaxPostDataSize = 10, IsReferer = false)]
        //public void ReworkTestDatas(string token, int problemId, diantou.dataAccess.problemTestData[] datas, Action<fastCSharp.net.returnValue<bool>> onReturn)
        //{
        //    if (token == null || datas.length() == 0) onReturn(false);
        //    else diantou.dataAccess.tcpCall.openJudge.reworkTestData(token, problemId, datas, onReturn);
        //}
        ///// <summary>
        ///// 修改测试数据
        ///// </summary>
        ///// <param name="token"></param>
        ///// <param name="data"></param>
        ///// <param name="onReturn"></param>
        //[fastCSharp.code.cSharp.ajax(MaxPostDataSize = 10, IsReferer = false)]
        //public void ReworkTestData(string token, diantou.dataAccess.problemTestData data, Action<fastCSharp.net.returnValue<bool>> onReturn)
        //{
        //    if (token == null || data == null) onReturn(false);
        //    else diantou.dataAccess.tcpCall.openJudge.reworkTestData(token, data, onReturn);
        //}
        //4.修改或者添加测试数据，POST最大限度为10MB
        //URI		https://www.51nod.com/ajax?n=api.problem.ReworkTestData
        //POST+JSON	{token:"",data:{ProblemId:1000,TestId:1,Input:"",Output:""}}
        //Response	{"Return":true/false);

        //5.批量修改或者添加测试数据，POST最大限度为10MB
        //URI		https://www.51nod.com/ajax?n=api.problem.ReworkTestDatas
        //POST+JSON	{token:"",problemId:1000,datas:[{TestId:1,Input:"",Output:""}]}
        //Response	{"Return":true/false);
        /// <summary>
        /// 删除测试数据
        /// </summary>
        /// <param name="token"></param>
        /// <param name="problemId"></param>
        /// <param name="datas"></param>
        /// <param name="onReturn"></param>
        [fastCSharp.code.cSharp.ajax(MaxPostDataSize = 10, IsReferer = false)]
        public void DeleteTestData(string token, int problemId, int testId, Action<fastCSharp.net.returnValue<fastCSharp.openApi._51nod.returnValue.value>> onReturn)
        {
            if (token == null) onReturn(default(fastCSharp.openApi._51nod.returnValue.value));
            else diantou.dataAccess.tcpCall.openJudge.deleteTestData(token, problemId, testId, onReturn);
        }
    }
}
